home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 62
/
Volume 62 - JOGO DISK .iso
/
Games
/
mycutepets.swf
/
scripts
/
frame_4
/
DoAction.as
< prev
Wrap
Text File
|
2008-03-17
|
10KB
|
365 lines
function playGameSound()
{
var _loc1_ = undefined;
do
{
_loc1_ = random(3);
}
while(index_sound == _loc1_);
index_sound = _loc1_;
switch(index_sound)
{
case 0:
sound_MC.playing = "bg1";
break;
case 1:
sound_MC.playing = "bg2";
break;
default:
sound_MC.playing = "bg3";
}
}
function getTool()
{
return game._tool;
}
function setTool(t)
{
cat.onPickTool(t);
dog.onPickTool(t);
pony.onPickTool(t);
game._tool.active = false;
t.active = true;
if(t != null)
{
Mouse.hide();
if(t.shakeType == 0)
{
onMouseMove = function()
{
var _loc2_ = new Array();
if(cat.enjoying != true && cat.need == t.id && cat.hitTest(_xmouse,_ymouse,true))
{
_loc2_.push(cat);
}
if(dog.enjoying != true && dog.need == t.id && dog.hitTest(_xmouse,_ymouse,true))
{
_loc2_.push(dog);
}
if(pony.enjoying != true && pony.need == t.id && pony.hitTest(_xmouse,_ymouse,true))
{
_loc2_.push(pony);
}
self[cat.mouse].gotoAndStop(1);
self[dog.mouse].gotoAndStop(1);
self[pony.mouse].gotoAndStop(1);
if(_loc2_.length > 0)
{
var _loc1_ = _loc2_.length - 1;
while(_loc1_ >= 0)
{
if(self[_loc2_[_loc1_].mouse]._currentframe != 2)
{
self[_loc2_[_loc1_].mouse].gotoAndStop(2);
}
_loc1_ = _loc1_ - 1;
}
}
};
}
else if(t.shakeType != 3)
{
if(t.shakeType == 1 || t.shakeType == 2)
{
var old = [_xmouse,_ymouse][t.shakeType - 1];
var pets;
onMouseMove = function()
{
pets = new Array();
if(cat.enjoying != true && cat.need == t.id && cat.hitTest(_xmouse,_ymouse,true))
{
pets.push(cat);
}
if(dog.enjoying != true && dog.need == t.id && dog.hitTest(_xmouse,_ymouse,true))
{
pets.push(dog);
}
if(pony.enjoying != true && pony.need == t.id && pony.hitTest(_xmouse,_ymouse,true))
{
pets.push(pony);
}
if(pets.length > 0)
{
if(t.mov2tg._currentframe != 2)
{
t.mov2tg.gotoAndStop(2);
}
var _loc3_ = Math.abs([_xmouse,_ymouse][t.shakeType - 1] - old) / 10;
var _loc2_ = pets.length - 1;
while(_loc2_ >= 0)
{
pets[_loc2_].full += _loc3_;
pets[_loc2_].inAction = true;
delete pets[_loc2_].actionCountrol;
if(pets[_loc2_].full >= 100)
{
pets[_loc2_].goEnjoy(function()
{
this.full = 100;
this.happy += happyIncrement;
this.inAction = false;
showPoint(this,animal.points[this.need]);
point += animal.points[this.need];
this.need = 0;
}
);
}
_loc2_ = _loc2_ - 1;
}
old = [_xmouse,_ymouse][t.shakeType - 1];
}
else
{
t.mov2tg.gotoAndStop(1);
}
dog.actionCountrol();
cat.actionCountrol();
pony.actionCountrol();
if(pets.length > 0)
{
_loc2_ = pets.length - 1;
while(_loc2_ >= 0)
{
if(!pets[_loc2_].enjoying)
{
pets[_loc2_].actionCountrol = function()
{
this.inAction = false;
delete this.actionCountrol;
};
}
_loc2_ = _loc2_ - 1;
}
}
};
}
}
}
else
{
dog.actionCountrol();
cat.actionCountrol();
pony.actionCountrol();
if(game._tool.shakeType == 0)
{
var pets = new Array();
if(cat.enjoying != true && cat.need == game._tool.id && cat.hitTest(_xmouse,_ymouse,true))
{
pets.push(cat);
}
if(dog.enjoying != true && dog.need == game._tool.id && dog.hitTest(_xmouse,_ymouse,true))
{
pets.push(dog);
}
if(pony.enjoying != true && pony.need == game._tool.id && pony.hitTest(_xmouse,_ymouse,true))
{
pets.push(pony);
}
if(pets.length > 0)
{
var _loc4_ = game._tool;
var _loc2_ = pets.length - 1;
while(_loc2_ >= 0)
{
pets[_loc2_].inAction = true;
pets[_loc2_].onFinished = function()
{
this.happy += happyIncrement;
this.full = 100;
this.inAction = false;
showPoint(this,animal.points[this.need]);
delete this.onFinished;
point += animal.points[this.need];
this.need = 0;
};
_loc2_ = _loc2_ - 1;
}
}
}
delete onMouseMove;
Mouse.show();
}
game._tool = t;
}
function showPoint(tag, p)
{
attachMovie("score_" + p,"point_" + getNextHighestDepth(),getNextHighestDepth(),{_x:pointLocal[tag._name]._x,_y:pointLocal[tag._name]._y});
}
function clearGame()
{
clearInterval(gameTunerITV);
clearInterval(gameTimerITV);
game.tool.active = false;
game.tool.using = false;
game.tool = null;
dog.clearIntervals();
cat.clearIntervals();
pony.clearIntervals();
}
function finished()
{
clearGame();
switch(type)
{
case "normal":
gotoAndStop("win2");
break;
case "hard":
gotoAndStop("win");
break;
default:
gotoAndStop("win1");
}
sound_MC.playing = "win";
}
function lost()
{
clearGame();
sound_MC.playing = "lost";
gotoAndStop("lost");
}
function timeCount()
{
time -= 1000;
if(time <= 0)
{
finished();
}
}
function rungame(t)
{
switch(type)
{
case "normal":
happyDecreaseITV = 1500;
happyIncrement = 30;
loop = 3500;
break;
case "hard":
clearInterval(gameTunerITV);
gameTunerITV = setInterval(function()
{
self.loop -= 500;
if(self.loop <= 10)
{
self.loop = 10;
clearInterval(self.gameTunerITV);
}
self.cat.loop = self.loop;
self.dog.loop = self.loop;
self.pony.loop = self.loop;
}
,120000);
happyDecreaseITV = 1200;
happyIncrement = 25;
loop = 2500;
break;
default:
happyDecreaseITV = 2000;
happyIncrement = 40;
loop = 5000;
}
waitTimeLoop = 50;
point = 0;
if(t > 0)
{
time = t;
gameTimerITV = setInterval(timeCount,1000);
}
else
{
time = -1;
}
if(_root.no_more_how_to_play != 1)
{
gotoAndStop("intro2");
}
else
{
gotoAndStop("game");
}
}
function getTime()
{
return _time;
}
function setTime(num)
{
_time = num;
if(num >= 0)
{
timeStr = "<font color=\'#" + (num <= 20 ? "ff0000" : "00ff00") + "\'>" + ("00" + int(num / 60000)).substr(-2) + ":" + ("00" + int(num / 1000) % 60).substr(-2) + "</font>";
}
else
{
timeStr = "UnLtd.";
}
}
_global.root = this;
var index_sound;
var my_so = SharedObject.getLocal("superfoo");
if(my_so.data.itemNumbers == 1)
{
_root.firstrun = false;
}
else
{
_root.firstrun = true;
}
stop();
var self = this;
_global.so = SharedObject.getLocal("my_cute_pets");
if(so.data.records.version != 3)
{
var initHistoary = function()
{
var _loc1_ = new Array();
_loc1_.push({id:1,name:"Player",score:100000});
_loc1_.push({id:2,name:"Player",score:75000});
_loc1_.push({id:3,name:"Player",score:50000});
_loc1_.push({id:4,name:"Player",score:40000});
_loc1_.push({id:5,name:"Player",score:30000});
_loc1_.push({id:6,name:"Player",score:25000});
_loc1_.push({id:7,name:"Player",score:20000});
_loc1_.push({id:8,name:"Player",score:10000});
_loc1_.push({id:9,name:"Player",score:10000});
_loc1_.push({id:10,name:"Player",score:5000});
return _loc1_;
};
so.data.records = new Object();
so.data.records.version = 3;
so.data.records.easy = initHistoary();
so.data.records.normal = initHistoary();
so.data.records.hard = initHistoary();
so.data.records.all = initHistoary();
so.flush();
}
var point;
var limit;
var limit2;
var game = new Object();
game.addProperty("tool",getTool,setTool);
var pointLocal = {cat:{_x:104,_y:132},dog:{_x:228,_y:132},pony:{_x:464,_y:132}};
var gameTunerITV;
var gameTimerITV;
var type = "hard";
var loop;
var waitTimeLoop;
var happyIncrement;
var happyDecreaseITV;
var timeStr;
var time;
var _time;
addProperty("time",getTime,setTime);